package com.company;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class lists {
    private List list;
    public lists() {
        List<String> lists = new ArrayList<>();
        this.list = lists;
        setList("ldq");
        setList("ltx");
        setList("link");
        System.out.println(getList(0));
        System.out.println(forList());
        System.out.println(size());
        iterator(this.list);
        forEach(this.list);
        getArray(this.list);
        System.out.println(isExistence(this.list,"ldq"));
        System.out.println(indexOf(this.list,"ldq"));
    }

    public Object setList(String ele) {
        return this.list.add(ele);
    }

    public Object getList(int index) {
        System.out.println("================");
        return this.list.get(index);
    }

    public String forList() {
        System.out.println("================");
        String ret = "";
        for (int i = 0; i < this.list.size(); i++) {
            ret += this.list.get(i);
        }
        return ret;
    }
    public Integer size() {
        System.out.println("================");
        return this.list.size();
    }
    public void iterator(List list){
        System.out.println("================");
        for (Iterator<String> it = list.iterator();it.hasNext();){
            String s = it.next();
            System.out.println(it.hasNext());
        }
    }
    public void forEach(List list){
        System.out.println("================");
        for(Object s : list){
            System.out.println(s);
        }
    }

    public Object[] getArray(List list){
        return list.toArray();
    }

    public boolean isExistence(List list,String ele){
        return list.contains(ele);
    }
    public Integer indexOf(List list,String ele){
        return list.indexOf(ele);
    }
}
